package com.xlisteven.controller;

import com.xlisteven.entity.CommonResult;
import com.xlisteven.entity.Product;
import com.xlisteven.service.IProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品
 *
 * @author xlisteven
 * @date 2022/09/28
 */
@RestController
@RequestMapping("product")
@Slf4j
public class ProductController {

    @Resource
    private IProductService productService;

    @GetMapping("getProductList/{userId}")
    public List<Product> getProductList(@PathVariable(name = "userId") long userId) {
        List<Product> productList = productService.getProductList(userId);
        log.info("查询商品结果,{}",productList);
        return productList;
    }

    @PostMapping("insert")
    public void insert(@RequestBody List<Product> productList){
        productService.insert(productList);
    }
}
